package densetsu.view;

import java.awt.Graphics;
import java.awt.event.KeyAdapter;
import java.awt.event.MouseAdapter;
import java.util.Observable;

import javax.swing.JFrame;

import densetsu.model.Model;

/**
 * Frame that contains the panel with the games' graphics.
 * 
 * @author Koen
 * 
 */
public class GameView extends JFrame implements View {

	private static final long serialVersionUID = -4340519570317823176L;
	public static final int SIZE = 800;

	private GamePanel gamePanel;

	public GameView ( Model model ) {
		super ( "Densetsu" );
		setResizable ( false );
		setDefaultCloseOperation ( EXIT_ON_CLOSE );
		setFocusable ( true ); // Needed for keyboard input I think

		gamePanel = new GamePanel ( model );
		getContentPane ( ).add ( gamePanel );
		pack ( );
		setLocationRelativeTo ( null );
		setVisible ( true );
	}

	@Override
	public void update ( Observable o, Object arg ) {
		repaint ( );
	}

	@Override
	public void paint ( Graphics g ) {
		gamePanel.repaint ( );
	}

	@Override
	public GamePanel getPanel ( ) {
		return this.gamePanel;
	}

	@Override
	public void addKeyAdapter ( KeyAdapter keyboardHandler ) {
		this.addKeyListener ( keyboardHandler );

	}

	@Override
	public void addMouseAdapter ( MouseAdapter mouseHandler ) {
		this.addMouseListener ( mouseHandler );
	}

}
